#ifndef CTEXTFIELD_H_
#define CTEXTFIELD_H_
#include "CFont.h"
#include <vector>
using namespace std;

/*  Notes
    For future dev:
        polymorph textfield class from generic canvas class
        add the ability to change text and have a cursor
		add a slider for use with the mouse
*/

class TextField
{
   private:
   CFont * font;                // font being used
   unsigned width;                 //(in characters)
   unsigned height;               //(in lines)
   unsigned x1,y1,x2,y2;           // top left, bottom right
   unsigned char_width;            // width of each letter
   unsigned char_height;           // height of each letter (determines line spacing);
   unsigned max_lines;             // the number of lines alotted for writing
   unsigned border_thickness;      // line thickness of the border
   unsigned padding;
   float text_color[3];       // the color of the text
   float bg_color[3];         // the background color of the textbox
   float border_color[3];//***not in use due to laziness
   float transparency;        // background transparency
   bool on_off;               // draw textfield or not
   bool border;          //***not in use due to laziness
   bool text_wrap;			// go to the next line if needed
   unsigned curr_line;             // which line the cursor is on
   char ** text;              // contains text per line
   
   public:
   TextField() {};
   TextField(const TextField & text_field);
   void CreateField(CFont & font_, unsigned x_, unsigned y_, unsigned width_, unsigned height_, unsigned max_lines_, bool text_wrap=1);
   void Write(const char * text_, ...);
   void Off(void) {on_off=0;} 
   void On(void) {on_off=1;}
   bool InUse() {return on_off;}
   void SetBorderThickness(unsigned thickness) {border_thickness=thickness;}
   void SetCharWidth(unsigned w_) {char_width=w_;}        // in pixels
   void SetCharHeight(unsigned h_) {char_height=h_;}      // in pixels
   void SetBGColor(float val1, float val2, float val3);
   void SetTransparency(float value) {transparency=value;}
   void Draw(void);

   TextField & operator=(const TextField & text_field); 
   ~TextField();
};

class TextFieldManager
{
private:
	vector<TextField> text_fields;
	unsigned currentIndex;
	bool on_off;
public:
	TextFieldManager() {currentIndex=0; on_off=1;}
	~TextFieldManager() {}
	void draw();
	void addTextField(TextField textField);							// adds it to the text_fields vector
	bool removeTextField(unsigned index);							// returns wether index was a valid subscript
	bool nextField();
	void setState(bool state) {on_off=state;}
};
#endif
